<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * OtcTrading模型
 */
class OtcInterestLog extends ModelBase
{

    protected $insert = ['create_time','serial_number'];

    /**
     * 流水号自动完成
     */
    public function setSerialNumberAttr($value)
    {

        return 'IL'.date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8).rand(10000,99999);
    }



    /**
     * 连用户表
     */
    public function  user(){
        return $this->belongsTo('Member','user_id','id');
    }


    /**
     * 连OTC店铺表
     */
    public function shop(){
        return $this->belongsTo('OtcShop','shop_id','id');
    }
    /**
     * 连OTC店铺表
     */
    public function wallet(){
        return $this->belongsTo('Wallet','wallet_id','id');
    }


    /**
     * 连all表
     */
    public function allocation(){
        return $this->belongsTo('InterestAllocation','type','id');
    }

    /**
     * 获取状态信息
     */
    public function getStateTextAttr(){
        $arr=['','待发放','已发放'];
        return lang($arr[$this->state]);
    }

    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }

    /**
     * 时间自动完成
     */
    public function getCreateTimeAttr($value)
    {

        return date('Y-m-d H:i:s',$value);
    }







}
